﻿using System.Reflection;

namespace ECO.EventBus
{
    public class EventFactory
    {
        private static List<Assembly>?  Assemblies;
        private static readonly Lazy<Core.EventBus> _eventBus = new(() =>
        {
            return new Core.EventBusBuilder()
                    .UsePool(true)
                    .ScanCurrentAssembly(Assemblies)
                    .Build();
        });

        /// <summary>
        /// 不传参数，默认注入
        /// </summary>
        /// <param name="assembly"></param>
        /// <returns></returns>
        public static Core.EventBus Instance(List<Assembly>?  assemblies=default)
        {
            Assemblies = assemblies;
            return _eventBus.Value;
        }
    }
}